﻿
    public interface IInventoryService
    {
        bool CheckStock(int productId);
    }
    public class InventoryService : IInventoryService
    { 
        private readonly ILogger<InventoryService> _log;//声明记录InventoryService日志的工具
        public InventoryService(ILogger<InventoryService> log)=>_log = log;//利用构造函数进行依赖注入
        public bool CheckStock(int productId)
        {
            _log.LogInformation("检查库存{ProductId}", productId);
            return productId > 0;//模拟有库存
        }
    }


